<?php
/**
 * Php2Js
 * @author Nguyen Thanh Quyen
 * @since 1.0 - 25-08-2009
 */
class Php2Js {
    function Php2Js() {
    }
    /**
     * Php2JsArr
     * @param Array $arrPhp : format php
     * @return Object : the string html create array format js
     * @author Nguyen Thanh Quyen
     * @since 1.0 - 25-08-2009
     */
    public static function php2JsArr($arrPhp) {
    	$res = "{";
   		foreach ($arrPhp as $key => $value) {
			if (!is_array($value)) {
				if (!is_numeric($key)) {
					$key = "'" . $key . "'";
				}
				$res .= $key . ":'" . $value . "',";
			}
			else {
				if (!is_numeric($key)) {
					$key = "'" . $key . "'";
				}
				$res .= $key . ":" . self::php2JsArr($value) . ",";
			}
		}
		$res = substr($res, 0, strlen($res) - 1);
    	$res .= "}";
    	return $res;
    }
}
?>